const formatTime1 = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  // const hour = date.getHours()
  // const minute = date.getMinutes()
  // const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber1).join('-')}`
  // return `${[year].map(formatNumber1)}年${[month].map(formatNumber1)}月${[day].map(formatNumber1)}日 ${[hour, minute, second].map(formatNumber1).join(':')}`
  // return `${[year].map(formatNumber1)}年${[month].map(formatNumber1)}月${[day].map(formatNumber1)}日`
}

const formatNumber1 = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}

const formatTime2 = time => {
  const hour = time.getHours()
  const minute = time.getMinutes()
  const second = time.getSeconds()

  return `${[hour, minute, second].map(formatNumber2).join(':')}`
}

const formatNumber2 = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}

module.exports = {
  formatTime1,
  formatTime2
}

